﻿var dqColumnStr = "|!@#$%^&*|";
function returnParent(value) {//获取子窗体返回值
    var parent = window.dialogArguments; //获取父页面
    //parent.location.reload(); //刷新父页面
    if (parent != null && parent != "undefined") {
        window.returnValue = value; //返回值
        window.close(); //关闭子页面
    }
    return;
}
function dateConvert(value) {
    var reg = new RegExp('/', 'g');
    var d = eval('new ' + value.replace(reg, ''));
    return new Date(d).format('yyyy-MM-dd')
}
function showModalMany(me, url, dialogWidth, dialogHeight, callback) {
    var reValue = window.showModalDialog(url, window, "dialogHeight:" + dialogHeight + "px; dialogWidth:" + dialogWidth + "px;  status:off; scroll:no;");

    if (reValue == null) {
        return;
    }
    if (callback != null) {
        callback(reValue);
    }
}
function isInt(t) {
    t.value = t.value.replace(/[^0-9]/g, '')
}
//输入必须是字母、数字、下划线，并且字符串以字母开始。
function checkStringNum(value) {
    var v = $.trim(value);
    var patrn = /^[^a-zA-Z]/;
    var patrn2 = /\W/;
    if (patrn.test(value) || !patrn2.test(value)) {
        return false;
    }
    return true;
}
//是否为空
function IsNullOrEmpty(value) {
    var v = $.trim(value);
    if (v == "" || v == null || typeof (value).toLowerCase() == "undefined") return true;
    return false;
}

//返回到地址
function goto(url) {
    window.location.href = url;
}
//回退
function back() {
    window.history.back();
}
function ReplaceColumn(value) {
    if (value != null && value != "") {
        return value.replace("|!@#$%^&*|", "");
    }
    else
        return "";
}
function ReplaceToNew(value, tg) {
    if (value != null && value != "") {
        return value.replace("|!@#$%^&*|", tg);
    }
    else
        return "";
}


function getArrValue(cla, sp, tp) {
    var rt = new Array(); ;
    $(cla).each(function (d) {
        var v = $(this).val();
        if (tp == "text") {
            v = $(this).find("option:selected").text();
        }
        rt.push(v);
    });
    return rt.join(sp);
}

function getRadioArr(cla) {
    var rt = new Array(); ;
    $(cla).each(function (i, d) {
        if ($(this)[0].checked) {
            rt.push(d.value);
        }
    });
    return rt;
}
function TipDown() {
    $(".tipcontentInfo").toggle();
    $(".tip_upimg").toggle();
    $(".tip_downimg").toggle();
}

function showModalOnly(me, url) { //弹出窗体 ,单选
    var hidden = document.getElementById(me); //获取隐藏的控件
    if (hidden != null && hidden.value != null && hidden.value.length > 0) {
        alert("此处为单选，请先删除已有的选项，再次尝试选择。");
        return;
    }
    var reValue = window.showModalDialog(url, window, "dialogHeight:550px; dialogWidth:687px;  status:off; scroll:auto");

    if (reValue == null || reValue == "undefined" || reValue == "") {
        return; //如果返回值为空，就返回
    }
    var index = reValue.split("^"); //分割符 ^ 的位置
    if (index[0] == null || index[0] == "undefined" || index[0].length < 1) {
        return;
    }
    var hid = index[0].split('&'); //为隐藏控件赋值
    var view = index[1].split('&'); //显示值
    var content = ""; //需要添加到check中的内容

    if (hid != null && hid.length == 2) {
        var i = 0;

        if (hid[i] != "undefined" && hid[i] != "" && view[i + 1] != "undefined" && view[i + 1] != "") {

            content += '<table  id="' + hid[i]
            + '" class="deleteStyle"><tr><td><img src="/Images/del.gif" title="点击删除"  alt="删除" onclick=" deleteTable('
            + "'" + hid[i] + "'," + "'" + me + "'" + ');" /></td><td>' + view[i + 1] + '</td></tr></table>';

            hidden.value = hid[i]; //为隐藏控件赋值
            var c = document.getElementById("check" + me);
            c.innerHTML += content;
            return;
        }
    }
    alert("请只选择一条数据。");
    return;
}
function GetPath(id, fromType, getAll) {
    showModalMany('GetPath', '/SystemConfiguration/GetPath/?id=' + id + "&fromType=" + fromType + "&getAll=" + getAll + "&dbName=" + encodeURI(UrlArray["dbName"]), '900', '500');
}

function checkMaxNum(v, max) {
    v = v.replace(/\D/g, '');
    v = parseInt(v);
    if (v > 0) {
        if (v > max)
            return max;
        else
            return v;
    }
    else
        return "0";
}
function checkNum(v) {
    v = v.replace(/\D/g, ''); 
    v = parseInt(v);
    if (v > 0)
        return v;
    else
        return "0";
}
function checkNumEmpty(v) {
    v = v.replace(/\D/g, '');
    v = parseInt(v);
    if (v > 0)
        return v;
    else
        return "";
}
function checksql() {
    if ($.trim($("#txt_Host").val()) == "") {
        alert("地址不能为空！");
        return false;
    }
    if ($.trim($("#txt_Server").val()) == "") {
        alert("数据库名不能为空！");
        return false;
    }
    if ($.trim($("#txt_User").val()) == "") {
        alert("用户名不能为空！");
        return false;
    }
    if ($.trim($("#txt_Pass").val()) == "") {
        alert("密码不能为空！");
        return false;
    }
    return true;
}
function checkOra() {
    if ($.trim($("#txt_Part").val()) == "") {
        alert("端口不能为空！");
        return false;
    }
    return true;
}
function checkfile() {
    if ($.trim($("#txt_FileUrl").val()) == "") {
        alert("地址不能为空！");
        return false;
    }
    if ($.trim($("#txt_FileUser").val()) == "") {
        alert("用户名不能为空！");
        return false;
    }
    if ($.trim($("#txt_FilePass").val()) == "") {
        alert("密码不能为空！");
        return false;
    }
    return true;
}